package map;

import java.util.HashMap;
import java.util.Map;

/**
 * map:
 */
public class MapDemo1 {
    public static void main(String[] args) {
        Map<String,Integer> map = new HashMap<>();
        map.put("语文",99);
        map.put("数学",98);
        map.put("英语",97);
        System.out.println(map);
        Integer value =map.put("语文",10);//返回被替换的值
        System.out.println(map);
        System.out.println(value);//返回被替换的值

        value = map.get("体育");
        System.out.println(value);

        System.out.println("size:"+map.size());
        System.out.println("isEmpty:"+map.isEmpty());

        System.out.println("是否包含数学这个键:"+map.containsKey("数学"));
        System.out.println("是否包含99这个值:"+map.containsValue(99));
        value = map.remove("数学");//删除key为数学的键值对，返回删除key所对应的value值
        System.out.println(value);

        map.clear();
        System.out.println(map);
    }
}
